package com.cy.网络编程.tcp.work;

import java.net.Socket;
import java.util.List;

public class ServerMsgThread extends Thread {
    private Socket s;
    private List<Socket> socketList;

    public ServerMsgThread(Socket s, List<Socket> socketList) {
        this.s = s;
        this.socketList = socketList;
    }

    @Override
    public void run() {
        while (true) {
            //接受消息
            String msg = SocketUtil.rece(s);
            //接受消息把收到的消息发送出去 --> socketList
            for (Socket s : socketList) {
                if(s.equals(s)){
                    continue;
                }
                SocketUtil.send(s, msg);
            }
        }

    }
}
